package br.net.atasacramental.log.dao;
import java.util.Date;

import br.net.atasacramental.log.model.Log;
import br.net.atasacramental.util.ConexaoDB;

import java.util.List;
import java.util.HashMap;
import java.util.Map;
/**
* @author alexandre.araujo
*/
public class LogDAO{
	private String[][] ordemP = {{"idLog", "desc"}};
	@SuppressWarnings("unchecked")
    public List<Log> get() {
        return (List<Log>) ConexaoDB.get(Log.class,true,1,100,null,ordemP);
    }
    public Log getByIdLog(int idLogPk) {
        return (Log) ConexaoDB.getById(Log.class, idLogPk);
    }
    @SuppressWarnings("unchecked")
    public List<Log> getByMomento(Date momento) {
     	Map<String,Object> params = new HashMap<String, Object>();
     	params.put("momento", momento);
        return (List<Log>) ConexaoDB.get(Log.class,true,1,100,params,ordemP);
    }
    @SuppressWarnings("unchecked")
    public List<Log> getByPeriodoMomento(Date DtaI,Date DtaF){
    	DtaF.setTime(DtaF.getTime()+86399999L);
		return (List<Log>) ConexaoDB.getBetween(Log.class,true,1,100,"momento",DtaI,DtaF,ordemP);
	}
    @SuppressWarnings("unchecked")
    public List<Log> getByIdUsuarioFk(int idUsuarioFk) {
     	Map<String,Object> params = new HashMap<String, Object>();
     	params.put("idUsuarioFk", idUsuarioFk);
        return (List<Log>) ConexaoDB.get(Log.class,true,1,100,params,ordemP);
    }
    @SuppressWarnings("unchecked")
    public List<Log> getByServico(String servico) {
     	Map<String,Object> params = new HashMap<String, Object>();
     	params.put("servico", servico);
        return (List<Log>) ConexaoDB.get(Log.class,true,1,100,params,ordemP);
    }
    @SuppressWarnings("unchecked")
    public List<Log> getByArgs(String args) {
     	Map<String,Object> params = new HashMap<String, Object>();
     	params.put("args", args);
        return (List<Log>) ConexaoDB.get(Log.class,true,1,100,params,ordemP);
    }
    public boolean insert(Log l){
        return ConexaoDB.insert(l);
    }
    public boolean update(Log l){
        return ConexaoDB.update(l);
    }
    public boolean delete(Log l){
        return ConexaoDB.delete(l);
    }
}
